bannerState = 0;
function bannerFade() {
  if ($('#banner').length != 0) {
    switch (bannerState++) {
      case 0: $('#state-1').fadeIn(2000); setTimeout('bannerFade()', 3750); break;
      case 1: $('#state-1').stop().fadeOut(1500); setTimeout('bannerFade()', 750); break;
      case 2: $('#state-2').fadeIn(2000); setTimeout('bannerFade()', 3750); break;
      case 3: $('#state-2').stop().fadeOut(1500); setTimeout('bannerFade()', 750); bannerState = 0; break;
      /* 3000/2500 1500/1000 3000/4000 1500/1000 */
    }
  }
};

bgRotateEnabled = false;
bgImage = 0;
bgFadeOutDelay = 2000;
bgFadeInDelay = 1000;
bgRotateDelay = 4500;
function rotateBG() {
  if (bgRotateEnabled) {
    switch (bgImage++) {
      case 0: $('#headerimage2').fadeOut(0); $('#headerimage3').fadeOut(0); /*$('#headerimage4').fadeOut(0);*/ break;
      case 1: $('#headerimage1').fadeOut(bgFadeOutDelay); $('#headerimage2').fadeIn(bgFadeInDelay); break;
      case 2: $('#headerimage2').fadeOut(bgFadeOutDelay); $('#headerimage3').fadeIn(bgFadeInDelay); break;
      case 3: $('#headerimage3').fadeOut(bgFadeOutDelay); $('#headerimage1').fadeIn(bgFadeInDelay); bgImage = 1; break;
/*
      case 3: $('#headerimage3').fadeOut(bgFadeOutDelay); $('#headerimage4').fadeIn(bgFadeInDelay); break;
      case 4: $('#headerimage4').fadeOut(bgFadeOutDelay); $('#headerimage1').fadeIn(bgFadeInDelay); bgImage = 1; break;
*/
    }
    setTimeout('rotateBG()', bgRotateDelay);
  }
};

$().ready(function() {
  $('#coda-slider-0').codaSlider({
    dynamicArrows: false,
    dynamicTabs: false,
    autoSlide: true,
    autoSlideInterval: 5000,
    slideEaseFunction: 'fadeIn'
  });
  $('#coda-slider-1').codaSlider({
    dynamicArrows: false,
    dynamicTabs: false,
    autoSlide: true,
    autoSlideInterval: 5000
  });
  setTimeout('bannerFade()', 0);
  setTimeout('rotateBG()', 0);
});
